/**
 * Created by dukes on 2016/1/12.
 */
class RobRankItemRender extends eui.ItemRenderer{
    constructor(){
        super();
        this.skinName = "pet.RobRankItemSkin";
    }

    public dataChanged(){
        super.dataChanged();
        this.lab_rank.text = this.data.rank+"";
        this.lab_name.text = LimitStringLen(this.data.userName,7);
        this.lab_robed.text = GetNumString(this.data.hairs,false, true);
        this.btn_visit.visible = this.data.userId != Model.me.id;
        this.img_head.source = RES.getRes("default_head_"+(this.data.userId%5));
        if( this.data.userFigureurl && Model.me.platform != PlatformEnum.QQBROWSER)
            this.img_head.source = this.data.userFigureurl;
    }
    private onVisit(evt:egret.TouchEvent){
        SceneMgr.getInstance().switchScene(SceneMgr.SCENE_GETOUT, this.data);
    }
    private img_head:eui.Image;
    private lab_rank:eui.BitmapLabel;
    private lab_name:eui.Label;
    private lab_robed:eui.BitmapLabel;
    private btn_visit:eui.Image;
    public partAdded(name:string, instance:any){
        super.partAdded(name, instance);
        if( name == "img_head"){
            this.img_head = instance;
        }else if( name == "lab_rank"){
            this.lab_rank = instance;
            this.lab_rank.textAlign = "center";
        }else if( name == "lab_name"){
            this.lab_name = instance;
        }else if( name == "lab_robed"){
            this.lab_robed = instance;
        }else if( name == "btn_visit"){
            this.btn_visit = instance;
            this.btn_visit.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onVisit, this);
        }
    }
}